<!-- 
	Tollbar com o comportamento padrão de um CRUD
 -->

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:cc="http://java.sun.com/jsf/composite"
	xmlns:p="http://primefaces.prime.com.tr/ui"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:ui="http://java.sun.com/jsf/facelets">

<cc:interface>
	<cc:attribute name="managedbean" required="true"></cc:attribute>
	<cc:attribute name="widgetVar" required="true"></cc:attribute>
	<cc:attribute name="widgetBuscar" required="false"></cc:attribute>
</cc:interface>
<cc:implementation>
		<p:tooltip global="true" />
		<p:toolbar id="toolbar" styleClass="ui-widget-toolbar ">
			<p:toolbarGroup align="left">

				<p:commandButton type="push" value="Novo" image="ui-icon-document" immediate="true"
					actionListener="#{cc.attrs.managedbean.iniciarCadastrar}"
					rendered="#{!cc.attrs.managedbean.estadoCadastrando and !cc.attrs.managedbean.estadoEditando and cc.attrs.managedbean.permiteIncluir}"
					update="frmPagina" />

				<p:commandButton type="push" value="Buscar" image="ui-icon-search"
					oncomplete="lovPesquisa.show()" update="frmLovPesquisa"
					rendered="#{!cc.attrs.managedbean.estadoCadastrando and !cc.attrs.managedbean.estadoEditando and cc.attrs.managedbean.permitePesquisar}" />

				<p:commandButton type="push" value="Salvar" image="ui-icon-disk"
					actionListener="#{cc.attrs.managedbean.iniciarInserir}"
					rendered="#{cc.attrs.managedbean.estadoCadastrando || cc.attrs.managedbean.estadoEditando}"
					update="frmPagina, frmLovPesquisa" />

				<p:commandButton type="push" value="Cancelar"
					actionListener="#{cc.attrs.managedbean.cancelar}"
					image="ui-icon-circle-close" immediate="true"
					rendered="#{cc.attrs.managedbean.estadoCadastrando || cc.attrs.managedbean.estadoEditando  || cc.attrs.managedbean.estadoEditando}"
					update="frmPagina" />

				<p:commandButton type="push" value="Editar" image="ui-icon-pencil"
					actionListener="#{cc.attrs.managedbean.iniciarEditar}"
					rendered="#{cc.attrs.managedbean.estadoSelecionado and !cc.attrs.managedbean.estadoEditando and cc.attrs.managedbean.permiteAtualizar}"
					update="frmPagina" />

				<p:commandButton type="push" value="Exluir"
					actionListener="#{cc.attrs.managedbean.iniciarExcluir}"
					rendered="#{cc.attrs.managedbean.estadoSelecionado and !cc.attrs.managedbean.estadoEditando and cc.attrs.managedbean.permiteExcluir}"
					image="ui-icon-trash" update="frmPagina" />

				<p:commandButton type="push" value="Atualizar"
					image="ui-icon-arrowrefresh-1-s" immediate="true"
					rendered="#{cc.attrs.managedbean.estadoSelecionado and !cc.attrs.managedbean.estadoEditando and cc.attrs.managedbean.permiteExcluir}"
					update="frmPagina" />

			</p:toolbarGroup>
		</p:toolbar>
		
		<p:messages id="msgs" showDetail="true" />
</cc:implementation>
</html>